<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:th="http://www.thymeleaf.org"
	  lang="zh-cn">
<head>
	<meta content="云之讯,云通讯,云通讯平台" name="keywords"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
	<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
	<title>短信平台运营系统 - 押金 </title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
	<link th:href="@{/resources/css/bootstrap.min14ed.css?v=3.3.6}" rel="stylesheet">
	<link th:href="@{/resources/css/font-awesome.min93e3.css?v=4.4.0}" rel="stylesheet">
	<!-- jqgrid-->
	<link th:href="@{/resources/css/animate.min.css}" rel="stylesheet">
	<link th:href="@{/resources/css/plugins/sweetalert/sweetalert.css}" rel="stylesheet">

	<link th:href="@{/resources/css/style.min862f.css?v=4.1.0}" rel="stylesheet">
	<style>
		/* Additional style to fix warning dialog position */
		#alertmod_table_list_2 {
			top: 900px !important;
		}
	</style>
</head>
<body class="gray-bg"><div th:replace="stat :: statCode"></div>
<div class="wrapper wrapper-content animated fadeInRight">
	<div class="row">
		<div class="col-sm-12">
			<div class="ibox ">
				<div class="ibox-title">
					<h5 th:text="${'押金操作 > ' + data.operateType}"></h5>
				</div>
				<div class="ibox-content">
					<div class="pull-right tooltip-demo">
						<!--<a class="btn btn-danger btn-sm" data-toggle="tooltip" data-placement="top" title="返回" onclick="javascript:self.location=document.referrer;"><i class="fa fa-reply"></i>&nbsp;返回</a>-->
					</div>
					<div class="row">
						<div class="col-sm-12">
							<div class="table-responsive">
								<table class="table">
									<tr class="active">
										<th>代理商ID</th>
										<th>代理商名称</th>
										<th>手机号码</th>
										<th>余额（元）</th>
										<th>剩余佣金（元）</th>
										<th>返点剩余（元）</th>
										<th>押金（元）</th>
										<th>授信额（元）</th>
									</tr>
									<tr>
										<td th:text="${data.agent_id}"></td>
										<td th:text="${data.agent_name}"></td>
										<td th:text="${data.mobile}"></td>
										<td th:text="${data.balance}"></td>
										<td th:text="${data.commission_income}"></td>
										<td th:text="${data.rebate_income}"></td>
										<td th:text="${data.deposit}"></td>
										<td th:text="${data.amount}"></td>
									</tr>
								</table>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-sm-12">
							<form class="form-horizontal m-t" id="mainForm">
								<input type="hidden" name="agent_id" id="agent_id" th:value="${data.agent_id}"/>
								<input type="hidden" name="operateType" id="operateType" th:value="${data.operateType}"/>
								<div class="form-group">
									<label class="col-sm-3 control-label" th:text="${data.operateType +'金额（元）:'}"></label>
									<div class="col-sm-8">
										<input type="text" class="form-control" id="operateAmount" name="operateAmount" placeholder=""/>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label">备注:</label>
									<div class="col-sm-8">
										<input type="text" class="form-control" id="remark" name="remark" placeholder=""/>
									</div>
								</div>

								<div class="form-group">
									<div class="col-sm-12 col-sm-offset-3">
										<button type="button" class="btn btn-sm btn-success" onclick="save(this)">提交</button>
										<button type="button" class="btn btn-sm btn-error" onclick="goBack()">返回</button>
									</div>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script th:src="@{/resources/js/hex_ha_ha_ha_ha_ha.js}"></script>
<script th:src="@{/resources/js/jquery.min.js?v=2.1.4}"></script>
<script th:src="@{/resources/js/bootstrap.min.js?v=3.3.6}"></script>
<script th:src="@{/resources/js/plugins/peity/jquery.peity.min.js}"></script>
<script th:src="@{/resources/js/content.min.js?v=1.0.0}"></script>
<script th:src="@{/resources/js/date_format.min.js?v=1.0.0}"></script>
<script th:src="@{/resources/js/jquery.form.js?v=1.0.0}"></script>

<script th:src="@{/resources/js/plugins/sweetalert/sweetalert.min.js}"></script>
<script th:src="@{/resources/js/plugins/validate/jquery.validate.min.js}"></script>
<script th:src="@{/resources/js/layer/layer.js}"></script>
<script th:src="@{/resources/js/common.js?v=1.0.0}"></script>

<script th:inline="javascript">
    var validate;
    var msgTime = 1500;
    $(function () {
        $.validator.defaults.ignore = "";
        //表单验证规则
        validate = $("#mainForm").validate({
            rules: {
                operateAmount: {
                    required: true,
                    digits:true,
                    min:1,
                    max:1000000
                },
                remark: {
                    maxlength: 50
                }
            },
            messages: {
                operateAmount: {
                    required: '请输入金额',
                    digits:"请输入整数",
                    max:"请按规则输入范围（1-1,000,000）元金额",
                    min:"请按规则输入范围（1-1,000,000）元金额"
                },
                remark: {
                    maxlength: '备注内容请保持在50个字符以内'
                }
            }
        });
    })

    function save(btn) {
        if (!validate.form()) {
            return;
        }

        var saveUrl = [[@{/finance/depositOperate/edit}]];
        var options = {
            beforeSubmit: function () {
                $(btn).attr("disabled", true);
            },
            success: function (data) {
                layer.closeAll(); //疯狂模式，关闭所有层
                $(btn).attr("disabled", false);
                if (data == "" || data == null) {
                    return; //session超时
                }
                if (data.success) {
                    layer.msg(data.msg, {icon: 1, time: msgTime}, function () {
                        var mainUrl = [[@{/finance/agentFinance}]];
                        window.location.href = mainUrl;
                    });
                } else {
                    layer.msg(data.msg, {
                        icon: 2
                    });
                }
            },
            url: saveUrl,
            type: "post"
        };

        var agent_id = $("#agent_id").val();
        var operateAmount = $("#operateAmount").val();
        var info = "<b>代理商："+agent_id+"， "+$("#operateType").val()+"："+operateAmount+"元<b>";

        layer.confirm(info, function (index) {
            $("#mainForm").ajaxSubmit(options);
            layer.close(index);
        });
    }

    function goBack() {
        var mainUrl = [[@{/finance/agentFinance}]];
        window.location.href = mainUrl;
    }

</script>
</body>
</html>